package com.bbzn.device.client.service.impl.cwting;//package com.bbzn.device.client.service.ct.impl;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.bbzn.device.client.constant.YG;
//import com.bbzn.device.client.dto.ct.request.RequestCreateCommand;
//import com.bbzn.device.client.service.ct.OrderSendService;
//import com.ctg.ag.sdk.biz.AepDeviceCommandClient;
//import com.ctg.ag.sdk.biz.AepDeviceCommandLwmProfileClient;
//import com.ctg.ag.sdk.biz.aep_device_command.CreateCommandRequest;
//import com.ctg.ag.sdk.biz.aep_device_command.CreateCommandResponse;
//import org.springframework.stereotype.Component;
//
//import java.util.Map;
//
///**
// * @Author wulongbo
// * @Date 2021/9/11 11:09
// * @Version 1.0
// */
//@Component
//public class TcpOrLwm2mTcServiceImpl extends OrderSendBaseServiceImpl implements OrderSendService {
//
//    private static AepDeviceCommandClient client;
//
//    private static AepDeviceCommandLwmProfileClient lwmClient;
//
//    public static AepDeviceCommandClient getClient() {
//        if (client == null) {
//            synchronized (AepDeviceCommandClient.class) {
//                if (client == null) {
//                    client = AepDeviceCommandClient.newClient()
//                            .appKey(YG.APP_KEY)
//                            .appSecret(YG.APP_SECRET)
//                            .build();
//                }
//            }
//        }
//        return client;
//    }
//
//    @Override
//    public CreateCommandResponse createCommand(String masterKey, RequestCreateCommand requestCreateCommand, JSONObject sendMsg, Map<String, Object> otherParams) throws Exception {
//        // TCP和LWM2M协议透传的content内容：
//        JSONObject content = new JSONObject();
//        content.put("payload", sendMsg.toJSONString());
//        // 数据类型：1字符串，2十六进制
//        content.put("dataType", Integer.parseInt(otherParams.get("dataType").toString()));
//        requestCreateCommand.setContent(content);
//        // 1.bean对象转换成byte数组
//        byte[] body = JSON.toJSONString(requestCreateCommand).getBytes();
//        AepDeviceCommandClient client = getClient();
//        CreateCommandRequest request = new CreateCommandRequest();
//        // set your request params here
//        request.setParamMasterKey(masterKey);    // single value
//        request.setBody(body);    //具体格式见前面请求body说明
//        CreateCommandResponse createCommandResponse = client.CreateCommand(request);
//        System.out.println(createCommandResponse);
//        client.shutdown();
//        return createCommandResponse;
//    }
//}
